<?php

use Illuminate\Database\Seeder;
use Yangyifan\Administrator\Access\Model\Admin\Admin;
use Yangyifan\BuildDom\Form\FormItem\Upload\Option\File;

class AdminTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        echo "Start: " . __CLASS__ . " \r\n";

        Admin::create([
            'user_name'     => 'admin',
            'status'        => 1,
            'password'      => 123456,
            'mobile'        => '138' . mt_rand(11111111, 88888888),
            'email'         => 'admin@admin.com',
            'avatar'        => [(new File(['url' => 'http://ov2uat2y6.bkt.clouddn.com/3e02299703700735bf0136fab11de4f3.jpg']))->render()],
            'login_number'  => 1,
            'last_login_ip' => ip2long('8.8.8.8'),
        ]);

        factory(Admin::class, 50)->create()->each(function ($u) {
            $u->save(factory(Admin::class)->make()->toArray());
        });

        echo "Finished: " . __CLASS__ . " \r\n";
    }
}
